<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Namespace: utils</title>

    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">

    <h1 class="page-title">Namespace: utils</h1>

    




<section>

<header>
    
        <h2>
            <span class="ancestors"><a href="SPE.html">SPE</a>.</span>
        
        utils
        </h2>
        
    
</header>

<article>
    <div class="container-overview">
    
        
            <div class="description">A bunch of utility functions used throughout the library.</div>
        

        


<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line6">line 6</a>
    </li></ul></dd>
    

    

    

    
</dl>


        
    
    </div>

    

    

    

     

    

    
        <h3 class="subsection-title">Members</h3>

        
            
<h4 class="name" id=".types"><span class="type-signature">(static) </span>types<span class="type-signature"> :String</span></h4>




<div class="description">
    A map of types used by `SPE.utils.ensureTypedArg` and
`SPE.utils.ensureArrayTypedArg` to compare types against.
</div>



    <h5>Type:</h5>
    <ul>
        <li>
            
<span class="param-type">String</span>


        </li>
    </ul>





    <h5 class="subsection-title">Properties:</h5>

    

<table class="props">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>BOOLEAN</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">Boolean type.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>STRING</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">String type.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>NUMBER</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">Number type.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>OBJECT</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">Object type.</td>
        </tr>

    
    </tbody>
</table>




<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line13">line 13</a>
    </li></ul></dd>
    

    

    

    
</dl>






        
    

    
        <h3 class="subsection-title">Methods</h3>

        
            

    

    <h4 class="name" id=".arrayValuesAreEqual"><span class="type-signature">(static) </span>arrayValuesAreEqual<span class="signature">(array)</span><span class="type-signature"> &rarr; {Boolean}</span></h4>

    



<div class="description">
    Check if all items in an array are equal. Uses strict equality.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>array</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array</span>


            
            </td>

            

            

            <td class="description last">The array of values to check equality of.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line369">line 369</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    Whether the array's values are all equal or not.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Boolean</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id=".clamp"><span class="type-signature">(static) </span>clamp<span class="signature">(value, min, max)</span><span class="type-signature"> &rarr; {Number}</span></h4>

    



<div class="description">
    Clamp a number to between the given min and max values.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>value</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The number to clamp.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>min</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The minimum value.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>max</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The maximum value.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line230">line 230</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    The clamped number.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Number</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id=".ensureArrayInstanceOf"><span class="type-signature">(static) </span>ensureArrayInstanceOf<span class="signature">(arg, instance, defaultValue)</span><span class="type-signature"> &rarr; {Object}</span></h4>

    



<div class="description">
    Given an array of values, ensure the instances of all items in the array
matches the given instance constructor falling back to a default value if
the check fails.

If given value isn't an Array, delegates to `SPE.utils.ensureInstanceOf`.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>arg</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array</span>
|

<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">The value to perform the instanceof check on.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>instance</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last">The constructor of the instance to check against.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>defaultValue</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">A default fallback value if instance check fails</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line124">line 124</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    The given value if type check passes, or the default value if it fails.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Object</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id=".ensureArrayTypedArg"><span class="type-signature">(static) </span>ensureArrayTypedArg<span class="signature">(arg, type, defaultValue)</span><span class="type-signature"> &rarr; {boolean|string|number|object}</span></h4>

    



<div class="description">
    Given an array of values, a type, and a default value,
ensure the given array's contents ALL adhere to the provided type,
returning the default value if type check fails.

If the given value to check isn't an Array, delegates to SPE.utils.ensureTypedArg.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>arg</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array</span>
|

<span class="param-type">boolean</span>
|

<span class="param-type">string</span>
|

<span class="param-type">number</span>
|

<span class="param-type">object</span>


            
            </td>

            

            

            <td class="description last">The array of values to check type of.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>type</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">The type that should be adhered to.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>defaultValue</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>
|

<span class="param-type">string</span>
|

<span class="param-type">number</span>
|

<span class="param-type">object</span>


            
            </td>

            

            

            <td class="description last">A default fallback value.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line72">line 72</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    The given value if type check passes, or the default value if it fails.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">boolean</span>
|

<span class="param-type">string</span>
|

<span class="param-type">number</span>
|

<span class="param-type">object</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id=".ensureInstanceOf"><span class="type-signature">(static) </span>ensureInstanceOf<span class="signature">(arg, instance, defaultValue)</span><span class="type-signature"> &rarr; {Object}</span></h4>

    



<div class="description">
    Ensures the given value is an instance of a constructor function.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>arg</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">The value to check instance of.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>instance</code></td>
            

            <td class="type">
            
                
<span class="param-type">function</span>


            
            </td>

            

            

            <td class="description last">The constructor of the instance to check against.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>defaultValue</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">A default fallback value if instance check fails</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line101">line 101</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    The given value if type check passes, or the default value if it fails.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Object</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id=".ensureTypedArg"><span class="type-signature">(static) </span>ensureTypedArg<span class="signature">(arg, type, defaultValue)</span><span class="type-signature"> &rarr; {boolean|string|number|object}</span></h4>

    



<div class="description">
    Given a value, a type, and a default value to fallback to,
ensure the given argument adheres to the type requesting,
returning the default value if type check is false.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>arg</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>
|

<span class="param-type">string</span>
|

<span class="param-type">number</span>
|

<span class="param-type">object</span>


            
            </td>

            

            

            <td class="description last">The value to perform a type-check on.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>type</code></td>
            

            <td class="type">
            
                
<span class="param-type">String</span>


            
            </td>

            

            

            <td class="description last">The type the `arg` argument should adhere to.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>defaultValue</code></td>
            

            <td class="type">
            
                
<span class="param-type">boolean</span>
|

<span class="param-type">string</span>
|

<span class="param-type">number</span>
|

<span class="param-type">object</span>


            
            </td>

            

            

            <td class="description last">A default value to fallback on if the type check fails.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line49">line 49</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    The given value if type check passes, or the default value if it fails.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">boolean</span>
|

<span class="param-type">string</span>
|

<span class="param-type">number</span>
|

<span class="param-type">object</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id=".ensureValueOverLifetimeCompliance"><span class="type-signature">(static) </span>ensureValueOverLifetimeCompliance<span class="signature">(property, minLength, maxLength)</span><span class="type-signature"></span></h4>

    



<div class="description">
    Ensures that any "value-over-lifetime" properties of an emitter are
of the correct length (as dictated by `SPE.valueOverLifetimeLength`).

Delegates to `SPE.utils.interpolateArray` for array resizing.

If properties aren't arrays, then property values are put into one.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>property</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">The property of an SPE.Emitter instance to check compliance of.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>minLength</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The minimum length of the array to create.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>maxLength</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The maximum length of the array to create.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line157">line 157</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id=".interpolateArray"><span class="type-signature">(static) </span>interpolateArray<span class="signature">(srcArray, newLength)</span><span class="type-signature"> &rarr; {Array}</span></h4>

    



<div class="description">
    Performs linear interpolation (lerp) on an array.

For example, lerping [1, 10], with a `newLength` of 10 will produce [1, 2, 3, 4, 5, 6, 7, 8, 9, 10].

Delegates to `SPE.utils.lerpTypeAgnostic` to perform the actual
interpolation.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>srcArray</code></td>
            

            <td class="type">
            
                
<span class="param-type">Array</span>


            
            </td>

            

            

            <td class="description last">The array to lerp.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>newLength</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The length the array should be interpolated to.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line197">line 197</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    The interpolated array.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Array</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id=".lerp"><span class="type-signature">(static) </span>lerp<span class="signature">(start, end, delta)</span><span class="type-signature"> &rarr; {Number}</span></h4>

    



<div class="description">
    Perform a linear interpolation operation on two numbers.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>start</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The start value.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>end</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The end value.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>delta</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The position to interpolate to.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line329">line 329</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    The result of the lerp operation.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Number</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id=".lerpTypeAgnostic"><span class="type-signature">(static) </span>lerpTypeAgnostic<span class="signature">(start, end, delta)</span><span class="type-signature"> &rarr; {number|object|undefined}</span></h4>

    



<div class="description">
    Linearly interpolates two values of various types. The given values
must be of the same type for the interpolation to work.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>start</code></td>
            

            <td class="type">
            
                
<span class="param-type">number</span>
|

<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">The start value of the lerp.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>end</code></td>
            

            <td class="type">
            
                
<span class="param-type">number</span>
|

<span class="param-type">object</span>


            
            </td>

            

            

            <td class="description last">The end value of the lerp.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>delta</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The delta posiiton of the lerp operation. Ideally between 0 and 1 (inclusive).</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line280">line 280</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    The result of the operation. Result will be undefined if
                                              the start and end arguments aren't a supported type, or
                                              if their types do not match.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">number</span>
|

<span class="param-type">object</span>
|

<span class="param-type">undefined</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id=".randomColor"><span class="type-signature">(static) </span>randomColor<span class="signature">(attribute, index, base, spread)</span><span class="type-signature"></span></h4>

    



<div class="description">
    Given an SPE.Shader attribute instance, and various other settings,
assign Color values to the attribute.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>attribute</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">The instance of SPE.ShaderAttribute to save the result to.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>index</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The offset in the attribute's TypedArray to save the result from.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>base</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">THREE.Color instance describing the start color.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>spread</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">THREE.Vector3 instance describing the random variance to apply to the start color.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line454">line 454</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id=".randomFloat"><span class="type-signature">(static) </span>randomFloat<span class="signature">(base, spread)</span><span class="type-signature"> &rarr; {Number}</span></h4>

    



<div class="description">
    Given a start value and a spread value, create and return a random
number.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>base</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The start value.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>spread</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The size of the random variance to apply.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line409">line 409</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    A randomised number.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Number</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id=".randomVector3"><span class="type-signature">(static) </span>randomVector3<span class="signature">(attribute, index, base, spread, spreadClamp)</span><span class="type-signature"></span></h4>

    



<div class="description">
    Given an SPE.ShaderAttribute instance, and various other settings,
assign values to the attribute's array in a `vec3` format.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>attribute</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">The instance of SPE.ShaderAttribute to save the result to.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>index</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The offset in the attribute's TypedArray to save the result from.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>base</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">THREE.Vector3 instance describing the start value.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>spread</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">THREE.Vector3 instance describing the random variance to apply to the start value.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>spreadClamp</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">THREE.Vector3 instance describing the multiples to clamp the randomness to.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line426">line 426</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id=".randomVector3OnDisc"><span class="type-signature">(static) </span>randomVector3OnDisc<span class="signature">(attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp)</span><span class="type-signature"></span></h4>

    



<div class="description">
    Assigns a random vector 3 value to an SPE.ShaderAttribute instance, projecting the
given values onto a 2d-disc.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>attribute</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">The instance of SPE.ShaderAttribute to save the result to.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>index</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The offset in the attribute's TypedArray to save the result from.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>base</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">THREE.Vector3 instance describing the origin of the transform.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>radius</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The radius of the sphere to project onto.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>radiusSpread</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The amount of randomness to apply to the projection result</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>radiusScale</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">THREE.Vector3 instance describing the scale of each axis of the disc. The z-component is ignored.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>radiusSpreadClamp</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">What numeric multiple the projected value should be clamped to.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line577">line 577</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id=".randomVector3OnSphere"><span class="type-signature">(static) </span>randomVector3OnSphere<span class="signature">(attribute, index, base, radius, radiusSpread, radiusScale, radiusSpreadClamp)</span><span class="type-signature"></span></h4>

    



<div class="description">
    Assigns a random vector 3 value to an SPE.ShaderAttribute instance, projecting the
given values onto a sphere.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>attribute</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">The instance of SPE.ShaderAttribute to save the result to.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>index</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The offset in the attribute's TypedArray to save the result from.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>base</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">THREE.Vector3 instance describing the origin of the transform.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>radius</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The radius of the sphere to project onto.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>radiusSpread</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The amount of randomness to apply to the projection result</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>radiusScale</code></td>
            

            <td class="type">
            
                
<span class="param-type">Object</span>


            
            </td>

            

            

            <td class="description last">THREE.Vector3 instance describing the scale of each axis of the sphere.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>radiusSpreadClamp</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">What numeric multiple the projected value should be clamped to.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line519">line 519</a>
    </li></ul></dd>
    

    

    

    
</dl>
















        
            

    

    <h4 class="name" id=".roundToNearestMultiple"><span class="type-signature">(static) </span>roundToNearestMultiple<span class="signature">(n, multiple)</span><span class="type-signature"> &rarr; {Number}</span></h4>

    



<div class="description">
    Rounds a number to a nearest multiple.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>n</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The number to round.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>multiple</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The multiple to round to.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line341">line 341</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    The result of the round operation.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Number</span>


    </dd>
</dl>

    



        
            

    

    <h4 class="name" id=".zeroToEpsilon"><span class="type-signature">(static) </span>zeroToEpsilon<span class="signature">(value, randomise)</span><span class="type-signature"> &rarr; {Number}</span></h4>

    



<div class="description">
    If the given value is less than the epsilon value, then return
a randomised epsilon value if specified, or just the epsilon value if not.
Works for negative numbers as well as positive.
</div>









    <h5>Parameters:</h5>
    

<table class="params">
    <thead>
    <tr>
        
        <th>Name</th>
        

        <th>Type</th>

        

        

        <th class="last">Description</th>
    </tr>
    </thead>

    <tbody>
    

        <tr>
            
                <td class="name"><code>value</code></td>
            

            <td class="type">
            
                
<span class="param-type">Number</span>


            
            </td>

            

            

            <td class="description last">The value to perform the operation on.</td>
        </tr>

    

        <tr>
            
                <td class="name"><code>randomise</code></td>
            

            <td class="type">
            
                
<span class="param-type">Boolean</span>


            
            </td>

            

            

            <td class="description last">Whether the value should be randomised.</td>
        </tr>

    
    </tbody>
</table>






<dl class="details">

    

    

    

    

    

    

    

    

    

    

    

    

    
    <dt class="tag-source">Source:</dt>
    <dd class="tag-source"><ul class="dummy"><li>
        <a href="core_SPE.utils.js.html">core/SPE.utils.js</a>, <a href="core_SPE.utils.js.html#line245">line 245</a>
    </li></ul></dd>
    

    

    

    
</dl>













<h5>Returns:</h5>

        
<div class="param-desc">
    The result of the operation.
</div>



<dl>
    <dt>
        Type
    </dt>
    <dd>
        
<span class="param-type">Number</span>


    </dd>
</dl>

    



        
    

    

    
</article>

</section>




</div>

<nav>
    <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="SPE.Emitter.html">Emitter</a></li><li><a href="SPE.Group.html">Group</a></li><li><a href="SPE.ShaderAttribute.html">ShaderAttribute</a></li><li><a href="SPE.TypedArrayHelper.html">TypedArrayHelper</a></li></ul><h3>Namespaces</h3><ul><li><a href="SPE.html">SPE</a></li><li><a href="SPE.utils.html">utils</a></li></ul><h3><a href="global.html">Global</a></h3>
</nav>

<br class="clear">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.3</a> on Sat Nov 14 2015 15:30:50 GMT+0000 (GMT)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>